package com.yin.myproject.distributedlock;

import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.serialize.BytesPushThroughSerializer;

/**
 * @author Eason
 * @create 2018-03-06 15:22
 **/
public class TestDistributedLock {

    private final static String zkServers = "172.16.100.60:2181";


    public static void main(String[] args) throws Exception {
        ZkClient zkClient1 = new ZkClient(zkServers, 5000, 5000, new BytesPushThroughSerializer());
        ZkClient zkClient2 = new ZkClient(zkServers, 5000, 5000, new BytesPushThroughSerializer());
        ZkClient zkClient3 = new ZkClient(zkServers, 5000, 5000, new BytesPushThroughSerializer());
            SimpleDistributedLockMutex mutex1 = new SimpleDistributedLockMutex(zkClient1, "/Mutex");
        SimpleDistributedLockMutex mutex2 = new SimpleDistributedLockMutex(zkClient2, "/Mutex");
        SimpleDistributedLockMutex mutex3 = new SimpleDistributedLockMutex(zkClient3, "/Mutex");
        mutex1.acquire();
        mutex2.acquire();
        mutex3.acquire();
    }
}
